﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Formatters;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;
using System.Runtime.Serialization;
using System.Configuration;


namespace PermitsAndVisasLeadsSyncher.Helpers.Logging
{
    internal static class loggingConfiguration
    {
        public static LoggingConfiguration BuildProgrammaticConfig()
        {
            //Formatter
            TextFormatter formatter= 
                new TextFormatter("Timestamp: {timestamp(local)}{newline}Message: {message}");
            string logFileName = ConfigurationManager.AppSettings["LogFileFullName"];
            // Trace Listeners 
            var flatFileTraceListener = new FlatFileTraceListener(logFileName , "----------------------------------------", "----------------------------------------", formatter);

            // Build Configuration 
            var config = new LoggingConfiguration();
            config.AddLogSource(Category.General, SourceLevels.All, true).AddTraceListener(flatFileTraceListener);
            return config;
        }
    }
}
